﻿CREATE TABLE [dbo].[Calendar] (
    [CalendarDate]        DATE           NOT NULL,
    [InstitutionEntityID] INT            CONSTRAINT [DF_Calendar_EntityID] DEFAULT ((0)) NOT NULL,
    [DayTypeName]         NVARCHAR (100) NOT NULL,
    CONSTRAINT [PK_Calendar] PRIMARY KEY CLUSTERED ([CalendarDate] ASC, [InstitutionEntityID] ASC),
    CONSTRAINT [FK_Calendar_DayTypes] FOREIGN KEY ([InstitutionEntityID], [DayTypeName]) REFERENCES [dbo].[DayTypes] ([InstitutionEntityID], [DayTypeName]),
    CONSTRAINT [FK_Calendar_Entity] FOREIGN KEY ([InstitutionEntityID]) REFERENCES [dbo].[Entities] ([EntityID])
);

